package com.smart.campus.controller;


import com.smart.campus.dto.SecurityGuard;
import com.smart.campus.pojo.PagedResponse;
import com.smart.campus.pojo.ResponseResult;
import com.smart.campus.service.SecurityGuardServiceFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @BelongsProject: smart-campus
 * @BelongsPackage: com.smart.campus.controller
 * @Author: Y S Z
 * @CreateTime: 2024-10-07  11:13
 * @Description: TODO
 * @Version: 1.0
 */
@Api(tags = "保安管理")
@Slf4j
@RestController
@RequestMapping(value = "guard")
public class SecurityGuardController {
    @Autowired
    private SecurityGuardServiceFeign securityGuardServiceFeign;

    @ApiOperation(value = "保安管理列表查询", httpMethod = "POST", notes = "保安管理列表查询")
    @RequestMapping(value = "findSecurityGuardList")
    public ResponseResult<List<SecurityGuard>> findSecurityGuardList(){
        return new ResponseResult<>(200,"保安管理列表查询成功", securityGuardServiceFeign.findSecurityGuardList());
    }

    @ApiOperation(value = "保安管理列表分页查询", httpMethod = "POST", notes = "保安管理列表分页查询")
    @RequestMapping(value = "pageSecurityGuard")
    public ResponseResult<PagedResponse<SecurityGuard>> pageSecurityGuard(@RequestBody SecurityGuard securityGuard, @RequestParam(value = "pageNum")Integer pageNum, @RequestParam(value = "pageSize")Integer pageSize){
        return new ResponseResult<>(200,"保安管理列表分页查询成功",securityGuardServiceFeign.pageSecurityGuard(securityGuard,pageNum,pageSize));
    }

    @ApiOperation(value = "保安管理新增", httpMethod = "POST", notes = "保安管理新增")
    @RequestMapping(value = "addSecurityGuard")
    public ResponseResult addSecurityGuard(@RequestBody SecurityGuard securityGuard){
        try {
            securityGuardServiceFeign.addSecurityGuard(securityGuard);
            return new ResponseResult<>(200,"新增成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult<>(444,"新增失败");
        }
    }

    @ApiOperation(value = "保安管理删除", httpMethod = "POST", notes = "保安管理删除")
    @RequestMapping(value = "delSecurityGuard")
    public ResponseResult delSecurityGuard(@RequestParam(value = "id")Long id){
        try {
            securityGuardServiceFeign.delSecurityGuard(id);
            return new ResponseResult<>(200,"删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult<>(444,"删除失败");
        }
    }

    @ApiOperation(value = "保安管理回显", httpMethod = "POST", notes = "保安管理回显")
    @RequestMapping(value = "findSecurityGuardById")
    public ResponseResult<SecurityGuard> findSecurityGuardById(@RequestParam(value = "id")Long id){
        return new ResponseResult<>(200,"回显成功",securityGuardServiceFeign.findSecurityGuardById(id));
    }

    @ApiOperation(value = "保安管理修改", httpMethod = "POST", notes = "保安管理修改")
    @RequestMapping(value = "updSecurityGuard")
    public ResponseResult updSecurityGuard(@RequestBody SecurityGuard securityGuard){
        try {
            securityGuardServiceFeign.updSecurityGuard(securityGuard);
            return new ResponseResult<>(200,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult<>(444,"修改失败");
        }
    }
}
